package com.hisoft.web.common.utils;

import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class JStringUtils {
	public static void Write(String filename,String content) throws Exception{
		Writer out = new OutputStreamWriter(new FileOutputStream(filename), "GBK");
		out.write(content);
		out.close();
	}
	
	public static String Read(String filename) throws Exception{
		BufferedReader reader=new BufferedReader(new FileReader(filename));
        String inLine=reader.readLine();
        StringBuffer sb = new StringBuffer();
        while(inLine !=null)
        {
        	sb.append(inLine);
        	sb.append(System.getProperty("line.separator"));
        	inLine=reader.readLine();
        }
        return sb.toString();
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		StringBuffer buffer = new StringBuffer();
		String inputbuffer = JStringUtils.Read("d:/001 Leehom Wang 1.meb");
		//inputbuffer = "{\\colortbl ;\\red0\\green0\\blue0;}";
		String regex = "\\{([^{}]+)\\}";
		Pattern p = Pattern.compile(regex);
		Matcher m = p.matcher(inputbuffer);
		
		try {
			while (m.find()) {
				m.appendReplacement(buffer, "");
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		m.appendTail(buffer);
		
		System.out.println(buffer.toString());
		
		
	}

}
